import 'package:fluent_ui/fluent_ui.dart';
import 'package:provider/provider.dart';

import '../view_type.dart';
import 'semester_view_edit.dart';
import 'semester_view_list.dart';
import 'semester_view_model.dart';

class SemesterViewMain extends StatefulWidget {
  final ViewType type;
  final String? id;

  const SemesterViewMain({super.key, required this.type, this.id});

  @override
  State<SemesterViewMain> createState() => _SemesterViewMainState();
}

class _SemesterViewMainState extends State<SemesterViewMain> {
  @override
  Widget build(final BuildContext context) =>
      ChangeNotifierProvider<SemesterViewModel>(
        create: (_) => SemesterViewModel(),
        builder: (_, __) {
          if (widget.type == ViewType.list) {
            return const SemesterViewList();
          }
          return SemesterViewEdit(id: widget.id);
        },
      );
}
